Author: Alexey Romaniuha
Posted: 8/9/2007 12:00:00 PM
Question: Occasionally after application restart log files are not working. How can I fix this without making a second restart?
Solution: You should execute following two lines of code in order to bring logging back to life:
log4net.LogManager.ResetConfiguration();
log4net.Config.DOMConfigurator.Configure();
Sample .html page can look as follows:
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
log4net.LogManager.ResetConfiguration();
log4net.Config.DOMConfigurator.Configure();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Log wake up</title>
</head>
<body>
Done.
</body>
</html>
Prev Next